package second;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 客户端、服务器端，各开两个线程，实现读写，可以全双工通信，异步发送，异步接受。
 */
public class TcpServer {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(8081);

        while (true) {
            Socket socket=serverSocket.accept();

            new Thread(new SendMessageService(socket,"服务器端：")).start();
            new Thread(new ReceiveMessageService(socket)).start();

            System.out.println("请输入...");

        }
    }
}
